package com.central.scheduler.api.entity.treeview;

import com.central.common.enums.TaskType;
import com.central.scheduler.common.enums.ExecutionStatus;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.models.auth.In;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * @author Tindy
 * @date 2022/2/28
 * @describe
 */
@Getter
@Setter
public class Instance{
    private Long id;

    /**
     * node name
     */
    private String name;

    /**
     * node code
     */
    private Long code;

    /**
     * node type
     */
    private TaskType type;

    /**
     * node status
     */
    private ExecutionStatus state;

    /**
     * node start time
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    /**
     * node end time
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;


    /**
     * node running on which host
     */
    private String host;

    /**
     * node duration
     */
    private String duration;

    private Long subflowCode;

    private Long processInstanceId;

    public Instance() {
    }

    public Instance(Long id, String name, Long code, TaskType type,Long processInstanceId) {
        this.id = id;
        this.name = name;
        this.code = code;
        this.type = type;
        this.processInstanceId=processInstanceId;
    }

    public Instance(Long id, String name, Long code, TaskType type, ExecutionStatus state, Date startTime, Date endTime, String host, String duration, Long subflowCode,Long processInstanceId) {
        this.id = id;
        this.name = name;
        this.code = code;
        this.type = type;
        this.state = state;
        this.startTime = startTime;
        this.endTime = endTime;
        this.host = host;
        this.duration = duration;
        this.subflowCode = subflowCode;
        this.processInstanceId=processInstanceId;
    }

    public Instance(Long id, String name, Long code, TaskType type, ExecutionStatus state, Date startTime, Date endTime, String host, String duration,Long processInstanceId) {
        this(id, name, code, type, state, startTime, endTime, host, duration, 0l,processInstanceId);
    }

}
